package com.hao.springboot02web;

import com.hao.springboot02web.dao.DepartmentDao;
import com.hao.springboot02web.pojo.Department;
import org.junit.jupiter.api.Test;

import java.util.Scanner;

public class testDepartment {
    //获取所有信息
    @Test
    public void getAllDepartments(){
        DepartmentDao departmentDao = new DepartmentDao();
        for (Department departments : departmentDao.getAll()) {
            System.out.println(departments);
        }
    }
    //通过id获取部门信息
    public static void main(String[] args) {
        String msg=null;
        DepartmentDao departmentDao = new DepartmentDao();
        Scanner scanner = new Scanner(System.in);
        int id= Integer.parseInt(scanner.next());
        Department departmentById = departmentDao.getDepartmentById(id);
        if (departmentById!=null){
            msg =  departmentById.getDepartmentName();
        }else {
            msg="您输入的部门id("+id+")有误";
        }
        System.out.println(msg);
    }




    //通过id获取部门信息
//    @Test
//    public  void   getDepartmentById(){
//        DepartmentDao departmentDao = new DepartmentDao();
//        String msg = null;
//        Scanner scanner = new Scanner(System.in);
//        int id= Integer.parseInt(scanner.next());
//        Department departmentById = departmentDao.getDepartmentById(id);
//        if (departmentById!=null){
//          msg =  departmentById.getDepartmentName();
//        }else {
//            msg="您输入的部门id"+id+"有误";
//        }
//        System.out.println(msg);
//    }
}
